﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace AcmeSportsStore
{
    class PurchasedItemIndexerByItemId : Indexer
    {
        public class UniquenessBasedComparer : IComparer
        {
            public int Compare(object x, object y)
            {
                PurchasedItem piX = (PurchasedItem)x;
                PurchasedItem piY = (PurchasedItem)y;

                int res = piX.ItemId.CompareTo(piY.ItemId);
                if (res == 0)
                {
                    res = piX.UId.CompareTo(piY.UId);
                }
                return res;
            }
        }

        public class FieldComparer : IComparer
        {
            public int Compare(object x, object y)
            {
                PurchasedItem piX = (PurchasedItem)x;
                PurchasedItem piY = (PurchasedItem)y;

                int res = piX.ItemId.CompareTo(piY.ItemId);
                return res;
            }
        }

        public readonly static UniquenessBasedComparer UBComp
           = new UniquenessBasedComparer();

        public readonly static FieldComparer FComp
            = new FieldComparer();

        public PurchasedItemIndexerByItemId()
            : base(UBComp, FComp)
        {
        }
    }
}
